package com.dob.dbo.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;

public class DataSourceExample {
	
	@Autowired
	private DataSource dataSource;

	public DataSource getDataSource() {
		return dataSource;
	}

	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}
	
	public void getEmployee(){
		
		try{
			Connection con= dataSource.getConnection();
			Statement st=con.createStatement();
			ResultSet rs=st.executeQuery("SELECT * FROM EMPLOYEE WHERE EMPID= 233");
			if(rs.next()){
				System.out.println(rs.getString("EMPNAME"));
			}
		}catch (SQLException e) {
			System.out.println("Error occurs");
		}finally{
			//Close all the con,st and rs objet.
		}
		
	}
	
	
	

}
